﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Collections;
using System.Web.UI;

namespace Winnow.SharepointDesigner.Controls
{
    public class DisplayLayout : Control
    {
        private String _title = "Hello";

        public virtual String Title
        {
            get
            {
                return _title;
            }
            set
            {
                _title = value;
            }
        }

        private String _description = "Hello";

        public virtual String Description
        {
            get
            {
                return _description;
            }
            set
            {
                _description = value;
            }
        }

        protected override void CreateChildControls()
        {
            // Controls.Clear(); ;

            Panel pnlRoot = new Panel();
            Panel pnlHeading = new Panel();
            pnlHeading.Controls.Add(new LiteralControl("<span style=\"margin: 2px;\">" + Title + "</span>"));
            pnlRoot.Controls.Add(pnlHeading);
            pnlHeading.Attributes.Add("style", "background: #e9edf1;border: 1px solid #e1e5e9;margin: 4px 4px 0p 4px;");

            pnlHeading.Attributes.Add("onClick", "$('#pnlDetails" + this.ClientID + "').toggle('fast');");
            Panel pnlDetails = new Panel();
            pnlDetails.Attributes.Add("id", "pnlDetails" + this.ClientID );
            pnlRoot.Controls.Add(pnlDetails);
            pnlDetails.Attributes.Add("style", "border: 1px solid #e1e5e9; margin: 0px 4px 4p 4px;");
            Panel pnlDescription = new Panel();
            pnlDescription.Attributes.Add("style", "border-bottom: 1px solid #e1e5e9;");
            pnlDescription.Controls.Add(new LiteralControl("<span style=\"margin: 2px;\">" + Description + "</span>"));
            pnlDetails.Controls.Add(pnlDescription);
            foreach (var item in items)
            {
                pnlDetails.Controls.Add(item as Control);
            }


            Controls.Add(pnlRoot);

        }

        private ArrayList items = new ArrayList();

        protected override void AddParsedSubObject(object obj)
        {
            items.Add(obj);
        }
    }
}







